package com.youdianstar.app.common.util.dialog

import android.app.Dialog
import android.content.Context
import android.graphics.drawable.AnimationDrawable
import android.view.Gravity
import android.view.ViewGroup
import android.widget.ImageView
import com.youdianstar.app.common.R


/**
 * File: FrameLoadDialog
 * Author: 82149 Create: 2024/1/6 11:09
 * Changes (from 2024/1/6)
 * --------------------------------------------------
 * description:
 * ---------------------------------------------------
 *
 */
class FrameLoadDialog : Dialog {
    private var ivLoad : ImageView

    constructor(context: Context) : this(context,0)

    constructor(context: Context, themeResId: Int) : super(context,themeResId){
        setContentView(R.layout.base_load_frame)
        ivLoad = findViewById(R.id.iv_load)
        setCancelable(true)
        setCanceledOnTouchOutside(false)
        window?.setGravity(Gravity.CENTER)
        window?.setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
    }

    fun showLoading(){
        (ivLoad.background as AnimationDrawable).start()
        show()
    }

    fun dismissLoading(){
        (ivLoad.background as AnimationDrawable).stop()
        dismiss()
    }
}